﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace YmtAuth.Domain.Model.LoginCredential
{
    /// <summary>
    /// 用户登录凭证规格
    /// </summary>
    public static class UserLoginCredentialSpecifications
    {
        /// <summary>
        /// 认证规格
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Expression<Func<UserLoginCredential, bool>> Auth(string ukey, string password)
        {
            var encryptKey = UserLoginCredential.GenerateCredential(ukey, password);
            YmtSystem.CrossCutting.YmatouLoggingService.Debug("请求key {0},pas {1} 生成key {2}", ukey, password, encryptKey);
            return e => e._id == (object)encryptKey;
        }
        /// <summary>
        /// 验证客户端请求key 是否不合法。  
        /// <remarks>true 不合法</remarks>
        /// </summary>      
        /// <param name="key"></param>
        /// <returns></returns>
        public static Expression<Func<bool>> VerifyRequest(string key)
        {
            return () => string.IsNullOrEmpty(key);
        }
    }
}
